import { defHttp } from '/@/utils/http/axios';
import { GetRoleModel } from './model/roleModel';

enum Api {
  GetRoleList = '/role/list',
  GetRoleDetail = '/role/detail',
  CreateRole = '/role/create',
  UpdateRole = '/role/update',
  DeleteRole = '/role/del',
  GetRoleMenuList = '/role/getRoleMenuList',
  GetRolePermissionList = '/role/getRolePermissionList',
  BindRoleMenuAndPermission = '/role/bindRoleMenuAndPermission',
}

/**
 * @description: getRoleInfo
 */
export function getRoleList(params) {
  return defHttp.get<GetRoleModel>({ url: Api.GetRoleList, params });
}
export function getRoleDetail(params) {
  return defHttp.get<GetRoleModel>({ url: Api.GetRoleDetail, params });
}
export const createRole = (data) => {
  return defHttp.post<GetRoleModel>({ url: Api.CreateRole, data });
};
export const updateRole = (data) => {
  return defHttp.post<GetRoleModel>({ url: Api.UpdateRole, data });
};
export const deleteRole = (data) => {
  return defHttp.post<GetRoleModel>({ url: Api.DeleteRole, data });
};
export const getRoleMenuList = (params) => {
  return defHttp.get<GetRoleModel>({ url: Api.GetRoleMenuList, params });
};
export const getRolePermissionList = (params) => {
  return defHttp.get<GetRoleModel>({ url: Api.GetRolePermissionList, params });
};
export const bindRoleMenuAndPermission = (data) => {
  return defHttp.post<GetRoleModel>({ url: Api.BindRoleMenuAndPermission, data });
};
